import myRequest from '../request.js'

import dicts from '@/config/dicts.js'

// 全部分类
export const getAllCategories = () => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + '/purchaser/goods/category/tree/list', 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
export const getCategoriesGoods = (ids) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + '/purchaser/goods/goods/sku', 'get',
      { categoryPath: ids }).then(res => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
  })
}


// export const getAllCategories = () => {
//   return new Promise((resolve, reject) => {
//     myRequest(dicts.buyer + '/purchaser/goods/category/get/0', 'get').then(res => {
//       resolve(res)
//     }).catch((err) => {
//       reject(err)
//     })
//   })
// }

// 二级分类
// export const getsecondCategories = (id) => {
//   return new Promise((resolve, reject) => {
//     myRequest(dicts.buyer + '/purchaser/goods/category', 'get', id).then(res => {
//       resolve(res)
//     }).catch((err) => {
//       reject(err)
//     })
//   })
// }

